import javax.swing.*;
import java.util.Date;
import net.sf.nachocalendar.CalendarFactory;
import net.sf.nachocalendar.components.DateField;

/* This class makes the date field for the pop up mini calendar*/

public class DatePicker
{
   private DateField datefield;
   private int x;
   private int y;
   private int width;
   private int height;
   
   public DatePicker(int x, int y, int width, int height){
       datefield = CalendarFactory.createDateField();
       this.x = x;
       this.y = y;
       this.width = width;
       this.height = height;
   }
   
   public void initialize(JPanel panel){
       datefield.setBounds(x,y,width,height);
       datefield.setFont(new java.awt.Font("Cambria",java.awt.Font.PLAIN,14));
       panel.add(datefield);
    }
    
   public String getDate(){
        Date choosed = (Date) datefield.getValue();
        return (choosed.getYear()+1900)+"-"+(choosed.getMonth()+1)+"-"+choosed.getDate();
   }
    
   public void setDate(Date date){
        datefield.setValue(date);
   }
   
}
